Skip to content

Python: Autodetect version issue (26.2) [STUD-78782]#511

Open
viogroza wants to merge 2 commits intodevelopfrom
fix/STUD-78782_autodetect
Open

Python: Autodetect version issue (26.2) [STUD-78782]#511
viogroza wants to merge 2 commits intodevelopfrom
fix/STUD-78782_autodetect

Conversation

@viogroza
Copy link
Collaborator

Search for python and python3 when detecting python
Search in the install folder and in ../bin folder
Remove no longer needed preprocessor directive

Search for python and python3 when detecting python
Search in the install folder and in ../bin folder
Remove no longer needed preprocessor directive
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Python runtime autodetection to be more flexible across installations and simplifies OS detection logic by removing now-unneeded preprocessor guards.

Changes:

  • Extend Python autodetection to probe multiple executable names (python/python3) and locations (<path> and <path>/bin).
  • Refactor autodetection to try multiple candidates and aggregate failures for easier troubleshooting.
  • Remove #if NETCOREAPP guards around RuntimeInformation.IsOSPlatform(...) checks.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Activities/Shared/UiPath.Shared.Service/Client/Controller.cs Removes NETCOREAPP conditional around Windows detection.
Activities/Python/UiPath.Python/Service/PythonProxy.cs Removes NETCOREAPP conditional around Windows detection.
Activities/Python/UiPath.Python/Impl/Engine.cs Removes NETCOREAPP conditional around Windows detection.
Activities/Python/UiPath.Python/EngineProvider.cs Implements multi-candidate Python executable probing and aggregated failure handling.
Activities/Python/UiPath.Python.Host.Shared/PythonService.cs Removes NETCOREAPP conditional around Windows detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AlexMarinescuUiPath
Copy link
Contributor

branch name does not contain the package name
my suggestion: fix/python/python-scope-search-for-framework-in-path

@viogroza
Copy link
Collaborator Author

viogroza commented Feb 18, 2026

address part of the review comments in this file
code_review_fix_STUD-78782_autodetect.txt

  1. Resource leak
  2. Potential read of the process output before the process exit
  3. Typo

@viogroza
Copy link
Collaborator Author

viogroza commented Feb 18, 2026

branch name does not contain the package name my suggestion: fix/python/python-scope-search-for-framework-in-path

leave as it is for now (changing the name will require new PR)
@AlexMarinescuUiPath

@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 30 to 32
Proc?.Kill();
Proc?.Dispose();
Proc = null;
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proc?.Kill() can throw (e.g., process already exited / has no associated process / access denied). If that happens, Proc?.Dispose() and Proc = null won’t run, which can reintroduce the leak this method is trying to prevent. Consider wrapping Kill() in a try/catch (or checking HasExited first), and ensure Dispose() runs in a finally-like path.

Suggested change
Proc?.Kill();
Proc?.Dispose();
Proc = null;
var proc = Proc;
if (proc != null)
{
try
{
// Attempt to kill the process only if it has not already exited.
if (!proc.HasExited)
{
proc.Kill();
}
}
catch (InvalidOperationException)
{
// Process may have already exited or have no associated process; ignore in dispose path.
}
catch (System.ComponentModel.Win32Exception)
{
// Access denied or other OS-level issue; ignore in dispose path to avoid masking earlier errors.
}
finally
{
proc.Dispose();
Proc = null;
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +18 to 21
private static readonly string[] PythonExeWin = ["python.exe", "python3.exe"];
private static readonly string[] PythonLinux = ["python", "python3"];
private static readonly string[] PythonBinFolders = ["", "bin"];
private const string PythonVersionArgument = "--version";
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description mentions searching in the install folder and in the ../bin folder, but the current candidate generation only checks path and path/bin via PythonBinFolders = ["", "bin"]. If path can point at a .../lib location (common for some Python envs), the executable will be in a sibling ../bin and won’t be found. Consider adding an explicit ../bin candidate (e.g., include Path.Combine("..", "bin") in the folder list) and normalizing with GetFullPath after combining.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants